package com.etalk.crm.controller;

import com.alibaba.fastjson.JSONObject;
import com.etalk.crm.client.interfaces.SmsMessageClient;
import com.etalk.crm.pojo.Agents;
import com.etalk.crm.pojo.GradeLevel;
import com.etalk.crm.pojo.KcOrders;
import com.etalk.crm.pojo.LessonAndTeacher;
import com.etalk.crm.pojo.QuestionGrade;
import com.etalk.crm.pojo.Stores;
import com.etalk.crm.pojo.StuPreferences;
import com.etalk.crm.pojo.StudentInfo;
import com.etalk.crm.pojo.StudentLesson;
import com.etalk.crm.pojo.User;
import com.etalk.crm.service.*;
import com.github.pagehelper.PageInfo;
import io.swagger.annotations.Api;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.util.StringUtils;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.annotation.Resource;
import javax.servlet.http.HttpSession;
import java.time.LocalTime;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * @author Jordan
 * @date 2019/1/2 10:51
 * @description
 */
@Api(value = "学员信息卡", tags = "学员信息卡")
@Controller
@RequestMapping(value = "/student")
public class StudentController {

    @Resource
    private StudentInfoService studentInfoService;
    @Resource
    private KcOrdersService kcOrdersService;
    @Resource
    private LessonsService lessonsService;
    @Resource
    private SmsTemplateService smsTemplateService;
    @Resource
    private SmsMessageClient smsMessageClient;
    @Resource
    private QuestionService questionService;
    @Resource
    private UserService userService;
    @Resource
    private PersonService personService;
    @Resource
    private StuAutoBookClassTimeService stuAutoBookClassTimeService;

    @Value("${web.crm.old.url}")
    String oldCrmUrl;
    @Value("${interface.operate.xiaoe.url}")
    String operateSmallEUrl;
    @Value("${interface.iapp.url}")
    String iappUrl;
    @Value("${interface.booked.courese.url}")
    String bookedUrl;
    @Value("${web.crm.old.url}")
    String oldUrl;

    @GetMapping(value = "/info")
    public String getStudentInfo(Model model, @RequestParam("personId") int personId, Integer tab, Integer sscCheck, Integer remindId) {
        model.addAttribute("oldCrmUrl", oldCrmUrl);
        model.addAttribute("eMsgUrl", operateSmallEUrl);
        if (!StringUtils.isEmpty(tab)) {
            model.addAttribute("tab", tab);
        } else {
            model.addAttribute("tab", 0);
        }
        if (!StringUtils.isEmpty(sscCheck)) {
            model.addAttribute("sscCheck", sscCheck);
        } else {
            model.addAttribute("sscCheck", "");
        }
        if (!StringUtils.isEmpty(remindId)) {
            model.addAttribute("remindId", remindId);
        } else {
            model.addAttribute("remindId", "");
        }
        //学员信息
        model.addAttribute("student", studentInfoService.searchStudentInfo(personId));
        model.addAttribute("personId", personId);
        //学员订单信息
        model.addAttribute("orderList", kcOrdersService.searchOrderListByPersonId(personId, 1, 15));
        return "student/student_dynamics";
    }

    /**
     * 转发小E信息页面
     *
     * @param model    页面数据
     * @param personId 学员id
     * @return 转向小E页面
     */
    @GetMapping(value = "/emsg/record/{personId}")
    public String forwardEMsgAndRecord(Model model, @PathVariable("personId") int personId) {
        model.addAttribute("eMsgUrl", operateSmallEUrl);
        //学员id
        model.addAttribute("personId", personId);
        return "student/e_msg_record";
    }

    /**
     * 转约课页面
     *
     * @param model       页面数据
     * @param personId    学员id
     * @param tokenString token
     * @return crm约课页面
     */
    @GetMapping(value = "/booked/course/{personId}")
    public String forwardBookedCourse(Model model, @PathVariable("personId") int personId, @RequestParam("tokenString") String tokenString) {
        model.addAttribute("iappUrl", iappUrl);
        model.addAttribute("bookedUrl", bookedUrl);
        //学员id
        model.addAttribute("personId", personId);
        model.addAttribute("tokenString", tokenString);
        return "student/student_booked_class";
    }

    @GetMapping(value = "/change/record/list/page/{personId}")
    public String getStudentChangeRecordList(Model model, @PathVariable("personId") int personId, Integer pageNum, Integer pageSize) {

        if (pageNum == null || pageNum < 1) {
            pageNum = 1;
        }
        if (pageSize == null || pageSize < 1) {
            pageSize = 15;
        }
        model.addAttribute("pageInfo", studentInfoService.searchStudentChangRecordByPage(personId, pageNum, pageSize));

        return "student/student_change_record";
    }

    /**
     * 学员订单列表接口
     *
     * @param personId 学员id
     * @return 课程信息
     */
    @ResponseBody
    @PostMapping(value = "/order/list/{personId}/{pageNum}", produces = "application/json;charset=utf-8")
    public PageInfo<KcOrders> getStudentOrderList(@PathVariable("personId") Integer personId, @PathVariable("pageNum") Integer pageNum) {
        return kcOrdersService.searchOrderListByPersonId(personId, pageNum, 15);
    }

    /**
     * 学员已约课程列表接口
     *
     * @param personId 学员id
     * @return 课程信息
     */
    @ResponseBody
    @PostMapping(value = "/booked/list/{personId}/{pageNum}", produces = "application/json;charset=utf-8")
    public PageInfo<StudentLesson> getStudentBookedLesson(@PathVariable("personId") Integer personId, @PathVariable("pageNum") Integer pageNum) {
        return lessonsService.searchBookedList(personId, pageNum, 10);
    }

    /**
     * 学员已完成课程列表接口
     *
     * @param personId 学员id
     * @return 课程信息
     */
    @ResponseBody
    @PostMapping(value = "/completed/list/{personId}/{pageNum}", produces = "application/json;charset=utf-8")
    public PageInfo<StudentLesson> getStudentCompletedLesson(@PathVariable("personId") Integer personId, @PathVariable("pageNum") Integer pageNum) {
        return lessonsService.searchCompletedList(personId, pageNum, 10);
    }

    @ResponseBody
    @PostMapping(value = "/sms/template/list", produces = "application/json;charset=utf-8")
    public Map<String, Object> getTemplateSmsList() {
        Map<String, Object> resultMap = new HashMap<>(2);
        resultMap.put("data", smsTemplateService.searchSmsTemplateByState());
        resultMap.put("status", 1);
        return resultMap;
    }

    @ResponseBody
    @PostMapping(value = "/sms/template/{templateId}", produces = "application/json;charset=utf-8")
    public String sendTemplateSms(@PathVariable("templateId") int templateId, @RequestParam("paramsStr") String params) {

        return smsMessageClient.sendSmsTemplateMessage(templateId, params);
    }

    /*
     * @Author James
     * @Description 学员基本信息修改页面
     * @Date 15:50 2019/1/17
     * @Param
     * @return
     **/
    @GetMapping(value = "/info/edit")
    public String sendTemplateSms(int personId, Model model) {
        //年級列表
        List<QuestionGrade> QGradeList = questionService.selectQGradeList();
        model.addAttribute("QGradeList", QGradeList);
        List<Integer> ccSscRoleList = new ArrayList<>();
        /*查询SSC列表*/
        ccSscRoleList.add(8);
        ccSscRoleList.add(9);
        ccSscRoleList.add(15);
        List<User> sscList = userService.ccSscList(ccSscRoleList);
        model.addAttribute("sscList", sscList);
        //店铺列表
        List<Stores> storesList = personService.storesList();
        model.addAttribute("storesList", storesList);
        //活动列表
        List<Map<String, Object>> listPromotion = personService.selectExperienceInfo(1);
        model.addAttribute("listPromotion", listPromotion);
        //所属代理
        List<Agents> agentsList = personService.agentsList();
        model.addAttribute("agentsList", agentsList);
        //所属渠道
        List<Map<String, Object>> channeList = personService.channeList();
        model.addAttribute("channeList", channeList);
        //客户属性列表
        List<Map<String, Object>> listRevisit = personService.selectRevisitInfo(1);
        model.addAttribute("listRevisit", listRevisit);
        //personInfo studentInfo
        StudentInfo studentInfo = personService.selectStudentInfoByPersonId(personId);
        model.addAttribute("studentInfo", studentInfo);
        return "student/stu_info_edit";
    }

    @PostMapping(value = "/info/updatePassword", produces = "application/json;charset=utf-8")
    @ResponseBody
    public String updatePassword(String password, Integer personId) {
        StudentInfo studentInfo = new StudentInfo();
        studentInfo.setPassword(password);
        studentInfo.setPersonId(personId);
        int result = personService.updateByPersonId(studentInfo);
        Map<String, Object> resultMap = new HashMap<>(1);
        if (result > 0) {
            resultMap.put("code", 1);
        } else {
            resultMap.put("code", 0);
        }
        return JSONObject.toJSONString(resultMap);
    }

    @PostMapping(value = "/info/updateStuInfo", produces = "application/json;charset=utf-8")
    @ResponseBody
    public String updateStuInfo(@RequestBody StudentInfo studentInfo) {
        int result = personService.updateStuInfo(studentInfo);
        Map<String, Object> resultMap = new HashMap<>(1);
        if (result > 0) {
            resultMap.put("status", 1);
        } else if (result == -1) {
            //手机号已存在
            resultMap.put("status", -1);
        } else {
            resultMap.put("status", 0);
        }
        return JSONObject.toJSONString(resultMap);
    }


    /*
     * @Author James
     * @Description 学员添加页面
     * @Date 16:43 2019/1/22
     * @Param
     * @return
     **/
    @GetMapping(value = "/info/toAddPerson")
    public String toAddPerson(Model model) {
        //年級列表
        List<QuestionGrade> QGradeList = questionService.selectQGradeList();
        model.addAttribute("QGradeList", QGradeList);
        List<Integer> ccSscRoleList = new ArrayList<>();
        /*查询SSC列表*/
        ccSscRoleList.add(8);
        ccSscRoleList.add(9);
        ccSscRoleList.add(15);
        List<User> sscList = userService.ccSscList(ccSscRoleList);
        model.addAttribute("sscList", sscList);
        ccSscRoleList.clear();
        //查询cc列表
        ccSscRoleList.add(2);
        ccSscRoleList.add(10);
        ccSscRoleList.add(12);
        ccSscRoleList.add(14);
        List<User> ccList = userService.ccSscList(ccSscRoleList);
        model.addAttribute("ccList", ccList);
        //店铺列表
        List<Stores> storesList = personService.storesList();
        model.addAttribute("storesList", storesList);
        //客户属性列表
        List<Map<String, Object>> listRevisit = personService.selectRevisitInfo(1);
        model.addAttribute("listRevisit", listRevisit);
        //所属代理
        List<Agents> agentsList = personService.agentsList();
        model.addAttribute("agentsList", agentsList);
        //所属渠道
        List<Map<String, Object>> channeList = personService.channeList();
        model.addAttribute("channeList", channeList);

        //活动列表
        List<Map<String, Object>> listPromotion = personService.selectExperienceInfo(1);
        model.addAttribute("listPromotion", listPromotion);
        return "student/stu_info_add";
    }

    /**
     * 学员喜好 页面
     * @param personId 学员id
     * @param model 页面绑定数据
     * @author James
     * @description 学员喜好 页面
     * @date 16:43 2019/1/22
     * @return 页面
     */
    @GetMapping(value = "/info/toStuPreferences")
    public String toStuPreferences(int personId, Model model) {
        //常用约课时间列表
        /*List<StuPreferences> oftenClassTimeList = personService.selectOftenClassTimeConf();
        model.addAttribute("oftenClassTimeList", oftenClassTimeList);*/
        model.addAttribute("autoClassTimeList",stuAutoBookClassTimeService.searchAutoBookClassTimeByPersonId(personId));
        //et  信息备注选项列表  以及已选择的选项
        List<Map<String, Object>> listM = personService.selectSceneInfo(personId);
        List<Map<String, Object>> listMap = new ArrayList<>();
        List<Map<String, Object>> list = null;
        Map<String, Object> tempMapSS = null;
        Map<String, Object> tempMapSSI;
        for (Map<String, Object> stringObjectMap : listM) {
            if (tempMapSS == null || !stringObjectMap.get("sceneId").equals(tempMapSS.get("sceneId"))) {
                tempMapSS = new HashMap<>();
                tempMapSS.put("sceneId", stringObjectMap.get("sceneId"));
                tempMapSS.put("sceneCnName", stringObjectMap.get("sceneCnName"));
                tempMapSS.put("sceneMultiselect", stringObjectMap.get("multiselect"));
                list = new ArrayList<>();
                tempMapSSI = new HashMap<>(5);
                tempMapSSI.put("sceneInfoId", stringObjectMap.get("sceneInfoId"));
                tempMapSSI.put("sceneInfoCnName", stringObjectMap.get("sceneInfoCnName"));
                tempMapSSI.put("defaultVal", stringObjectMap.get("default"));
                tempMapSSI.put("exclusive", stringObjectMap.get("exclusive"));
                if (stringObjectMap.get("customValue") != null) {
                    tempMapSSI.put("customValue", stringObjectMap.get("customValue"));
                } else {
                    tempMapSSI.put("customValue", "");
                }
                list.add(tempMapSSI);
                tempMapSS.put("sceneInfoList", list);
                listMap.add(tempMapSS);
            } else {
                tempMapSSI = new HashMap<>(5);
                tempMapSSI.put("sceneInfoId", stringObjectMap.get("sceneInfoId"));
                tempMapSSI.put("sceneInfoCnName", stringObjectMap.get("sceneInfoCnName"));
                tempMapSSI.put("defaultVal", stringObjectMap.get("default"));
                tempMapSSI.put("exclusive", stringObjectMap.get("exclusive"));
                if (stringObjectMap.get("customValue") != null) {
                    tempMapSSI.put("customValue", stringObjectMap.get("customValue"));
                } else {
                    tempMapSSI.put("customValue", "");
                }
                list.add(tempMapSSI);
            }
        }
        //System.out.println(JSON.toJSONString(listMap));
        //适合年龄段列表
        List<GradeLevel> ageGroupList = personService.ageGroupList();
        model.addAttribute("ageGroupList", ageGroupList);
        //教学风格
        List<GradeLevel> teachingStyleList = personService.teachingStyleList();
        //性格
        List<GradeLevel> characterList = teachingStyleList.subList(0, 2);
        //基础
        List<GradeLevel> basicList = teachingStyleList.subList(2, teachingStyleList.size());
        model.addAttribute("characterList", characterList);
        model.addAttribute("BasicList", basicList);
        //线上图片链接
        model.addAttribute("oldUrl", oldUrl);
        model.addAttribute("listMap", listMap);
        model.addAttribute("personId", personId);
        //学员偏好设置
        StuPreferences stuPrefer = personService.stuPrefer(personId);

        //学员年龄 计算
        StudentInfo studentInfo = personService.stuAge(personId);
        if (stuPrefer == null) {
            stuPrefer = new StuPreferences();
        }
        if (studentInfo != null) {
            if (studentInfo.getAge() < 6) {
                stuPrefer.setAgeGroup(1);
            } else if (studentInfo.getAge() >= 6 && studentInfo.getAge() < 9) {
                stuPrefer.setAgeGroup(2);
            } else if (studentInfo.getAge() >= 9 && studentInfo.getAge() < 12) {
                stuPrefer.setAgeGroup(3);
            } else if (studentInfo.getAge() >= 12) {
                stuPrefer.setAgeGroup(4);
            }
        }
        model.addAttribute("stuPrefer", stuPrefer);
        return "student/studentPreferences";
    }


    /*
     * @Author James
     * @Description 保存学员偏好设置
     * @Date 13:35 2019/1/24
     * @Param
     * @return
     **/
    @RequestMapping(value = "/info/saveEtInfoInfo")
    @ResponseBody
    public String saveEtInfoInfo(@RequestBody JSONObject jsonObject, HttpSession session) {
        Map<String, Object> resultMap = new HashMap<>(1);
        int result = personService.addSceneInfo(jsonObject, session.getAttribute("loginname").toString());
        if (result > 0) {
            //修改成功
            resultMap.put("code", 1);
        } else {
            //修改失败
            resultMap.put("code", 0);
        }
        return JSONObject.toJSONString(resultMap);
    }


    /*
     * @Author James
     * @Description 历史老 五星bang
     * @Date 13:43 2019/1/25
     * @Param
     * @return
     **/
    @PostMapping(value = "/info/fiveStarTeacherPercent", produces = "application/json;charset=utf-8")
    @ResponseBody
    public String selectFiveStartTeacher(int personId, Integer page, Integer limit) {
        if (page == null) {
            page = 1;
        }
        if (limit == null) {
            limit = 5;
        }
        //历史老 五星bang
        PageInfo<LessonAndTeacher> pageInfo = personService.selectFiveStartTeacher(personId, page, limit);
        Map<String, Object> jsonMap = new HashMap<>(4);
        jsonMap.put("data", pageInfo.getList());
        jsonMap.put("code", 0);
        jsonMap.put("msg", "请求成功");
        jsonMap.put("count", pageInfo.getTotal());
        return JSONObject.toJSONString(jsonMap);
    }


    /*
     * @Author James
     * @Description 黑名单老师列表
     * @Date 14:21 2019/1/25
     * @Param
     * @return
     **/
    @PostMapping(value = "/info/blackListTeacher", produces = "application/json;charset=utf-8")
    @ResponseBody
    public String blackListTeacher(int personId) {
        //黑名单老师
        List<LessonAndTeacher> blackTeacherList = personService.selectBlackList(personId);
        Map<String, Object> jsonMap = new HashMap<>(3);
        jsonMap.put("code", 1);
        jsonMap.put("blackTeacherList", blackTeacherList);
        jsonMap.put("msg", "请求成功");
        return JSONObject.toJSONString(jsonMap);
    }

    /**
     * 删除黑名单老师
     *
     * @param
     * @Author James
     * @Date 14:21 2019/1/25
     */
    @PostMapping(value = "/info/delBadTeacher", produces = "application/json;charset=utf-8")
    @ResponseBody
    public String delBadTeacher(int id) {
        int result = personService.delBadTeacher(id);
        Map<String, Object> jsonMap = new HashMap<>(1);
        if (result > 0) {
            //删除成功
            jsonMap.put("code", 1);
        } else {
            //删除失败
            jsonMap.put("code", -1);
        }
        return JSONObject.toJSONString(jsonMap);
    }

    /**
     * 搜索老师
     *
     * @param teacherLogin
     * @Author James
     * @Date 14:21 2019/1/25
     */
    @PostMapping(value = "/info/searchByTeacherName", produces = "application/json;charset=utf-8")
    @ResponseBody
    public String searchByTeacherName(String teacherLogin) {
        List<LessonAndTeacher> searchByTeacherName = personService.searchByTeacherName(teacherLogin);
        Map<String, Object> jsonMap = new HashMap<>(2);
        jsonMap.put("code", 1);
        jsonMap.put("searchByTeacherName", searchByTeacherName);
        return JSONObject.toJSONString(jsonMap);
    }


    /*
     * @Author James
     * @Description 添加黑名单老师
     * @Date 12:48 2019/1/26
     * @Param
     * @return
     **/
    @PostMapping(value = "/info/addBadTeacher", produces = "application/json;charset=utf-8")
    @ResponseBody
    public String addBadTeacher(String teacherLogin, int personId) {
        //添加黑名单老师
        int result = personService.addBadTeacher(teacherLogin, personId);
        Map<String, Object> jsonMap = new HashMap<>(1);
        if (result > 0) {
            //成功
            jsonMap.put("code", 1);
        } else {
            //已存在
            jsonMap.put("code", -1);
        }
        return JSONObject.toJSONString(jsonMap);
    }

    /**
     * 分页查询系统推荐老师
     *
     * @return
     */
    @PostMapping(value = "/info/teacherLevelInfo", produces = "application/json;charset=utf-8")
    @ResponseBody
    public String selectTeacherLevelInfo(@RequestBody StuPreferences stuPreferences) {
        int page;
        int limit = 3;
        if (stuPreferences.getPage() == null) {
            page = 1;
        } else {
            page = stuPreferences.getPage();
        }
        if (stuPreferences.getLimit() == null) {
            stuPreferences.setLimit(3);
        }
        //历史老 五星bang
        PageInfo<LessonAndTeacher> pageInfo = personService.sysTeacherInfo(page, limit, stuPreferences);
        Map<String, Object> jsonMap = new HashMap<>(3);
        jsonMap.put("pageInfo", pageInfo);
        jsonMap.put("code", 1);
        jsonMap.put("msg", "请求成功");
        return JSONObject.toJSONString(jsonMap);
    }


    /*
     * @Author James
     * @Description 常用老师 信息
     * @Date 15:03 2019/1/26
     * @Param
     * @return
     **/
    @PostMapping(value = "/info/teacherInfoList", produces = "application/json;charset=utf-8")
    @ResponseBody
    public String commonlyUsedTeacherInfo(int personId) {
        List<LessonAndTeacher> teacherInfoList = personService.commonlyUsedTeacherInfo(personId);
        Map<String, Object> jsonMap = new HashMap<>(3);
        jsonMap.put("teacherInfoList", teacherInfoList);
        jsonMap.put("code", 1);
        jsonMap.put("msg", "请求成功");
        return JSONObject.toJSONString(jsonMap);
    }


    /*
     * @Author James
     * @Description 添加老师
     * @Date 18:04 2019/1/26
     * @Param
     * @return
     **/
    @PostMapping(value = "/info/addCommonlyUsedTeacher", produces = "application/json;charset=utf-8")
    @ResponseBody
    public String addCommonlyUsedTeacher(int personId, int teacherId) {
        int result = personService.addCommonlyUsedTeacher(personId, teacherId);
        Map<String, Object> jsonMap = new HashMap<>(1);
        if (result > 0) {
            //成功
            jsonMap.put("code", 1);
        } else if (result == -1) {
            //已存在
            jsonMap.put("code", -1);
        } else if (result == -2) {
            //常用老师已满
            jsonMap.put("code", -2);
        } else if (result == 0) {
            //失败
            jsonMap.put("code", 0);
        }
        return JSONObject.toJSONString(jsonMap);
    }


    /*
     * @Author James
     * @Description 保存学员偏好设置
     * @Date 10:40 2019/1/28
     * @Param
     * @return
     **/
    @PostMapping(value = "/info/stuPreferencesSave")
    @ResponseBody
    public String stuPreferencesSave(StuPreferences stuPreferences, HttpSession session) {
        stuPreferences.setAddUserName(session.getAttribute("loginname").toString());
        int result = personService.saveStuPrefer(stuPreferences);
        Map<String, Object> jsonMap = new HashMap<>(1);
        if (result > 0) {
            //成功
            jsonMap.put("code", 1);
        } else {
            //失败
            jsonMap.put("code", 0);
        }
        return JSONObject.toJSONString(jsonMap);
    }

    /**
     * 打开自动约课时间设置页面
     * @return
     */
    @GetMapping("/auto/class/setup/init")
    public String stuAutoBookedClassSetup(Model model, @RequestParam("personId") Integer personId, String orderId, Integer weekId){
        if (StringUtils.isEmpty(orderId)){
            orderId="";
        }
        if (StringUtils.isEmpty(weekId)){
            weekId=0;
        }
        Map<String,Object> map=stuAutoBookClassTimeService.searchAutoBookClassSetup(personId,orderId,weekId);
        model.addAllAttributes(map);
        model.addAttribute("personId",personId);
        return "student/auto_booked_class_setup";
    }

    /**
     * 保存自动约课设置
     * @param personId 学员id
     * @param orders 订单数据
     * @param weeks 星期几
     * @param classTimes 自动约课时间
     * @param session 会话对象
     * @return 结果
     */
    @PostMapping("/auto/class/setup/add/{personId}")
    @ResponseBody
    public Map<String,Object> addAutoBookedClassSetup(@PathVariable("personId") int personId, @RequestParam String[] orders, @RequestParam Integer[] weeks, String[] classTimes,HttpSession session){
        Map<String,Object> resultMap=new HashMap<>(3);
        if (orders==null || orders.length==0){
            resultMap.put("status",0);
            resultMap.put("errCode","1111");
            resultMap.put("errMsg","没有订单");
            return resultMap;
        }
        if (weeks==null || weeks.length==0){
            resultMap.put("status",0);
            resultMap.put("errCode","1111");
            resultMap.put("errMsg","没有星期数据");
            return resultMap;
        }
        List<LocalTime> localTimeList=new ArrayList<>();
        if (!StringUtils.isEmpty(classTimes)){
            for (String classTime:classTimes) {
                localTimeList.add(LocalTime.parse(classTime+":00"));
            }
        }
        int num=stuAutoBookClassTimeService.addAutoBookedClassSetup(personId,orders,weeks,localTimeList,session.getAttribute("loginname").toString());
        if (num>0){
            resultMap.put("status",1);
        }else {
            resultMap.put("status",0);
            resultMap.put("errCode",0000);
            resultMap.put("errMsg","保存配置失败");
        }

        return resultMap;
    }
}
